package com.itheima.inter.test.testdog;

public class testCat {
    public static void main(String[] args) {
        useAnmial(new Dog());
        useAnmial(new Cat());

    }
    public static void useAnmial(Anmial a){
        a.eat();
        if (a instanceof Dog) {
            Dog d = (Dog) a;
            d.watchHome();
        }
    }
}
abstract class Anmial{
    public abstract void eat();
}
class Dog extends Anmial{

    @Override
    public void eat() {
        System.out.println("狗吃肉");
    }
    public void watchHome(){
        System.out.println("看家");
    }
}
class Cat extends Anmial{
    @Override
    public void eat() {
        System.out.println("猫吃鱼");
    }
}
